package array;

import java.util.Random;

public class Array
{
	public static void main(String[] args)
	{
		int[][] array = new int[2][2];
		array = fillArray(2, 2);
		array = flipArray(array);
	}

	private static int[][] fillArray(int rows, int cols)
	{
		Random rnd = new Random();
		int[][] array = new int[rows][cols];
		for (int i = 0; i < rows; i++)
			for (int j = 0; j < cols; j++)
				array[i][j] = rnd.nextInt(7);

		return array;
	}

	private static int[][] flipArray(int[][] array)
	{
		int rows = array.length;
		int cols = array[0].length;
		int[] array1 = new int[cols];
		int[][] result = new int[rows][cols];
		
		for (int i = 0; i < rows; i++)
		{
			for (int j = 0; j < cols; j++)
			{
				array1[j] = array[i][j];
				if (j == cols - 1)
				{
					for (int k = 0; k < cols; k++)
						result[i][k] = array1[(array1.length - 1) - k];
				}
			}
			array1 = new int[cols];
		}
		return result;
	}
}
